import com.beans.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2023-01-08
 * Time: 13:46
 */
public class App {
    public static void main1(String[] args) {
        System.out.println("你好spring");
    }

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        UserController userController = context.getBean(UserController.class);
        userController.sayHi();

        UserService userService = context.getBean(UserService.class);
        userService.sayHi();

        //jdkde的源代码 beanname默认转成小驼峰(只有第一个字母大写)
        UserRepository userRepository = (UserRepository) context.getBean("userRepository");
        userRepository.sayHi();

        UserConfiguration userConfiguration = context.getBean("userConfiguration", UserConfiguration.class);
        userConfiguration.sayHi();

        UserComponent userComponent = context.getBean("userComponent", UserComponent.class);
        userComponent.sayHi();

    }
}
